const router = require('koa-router')();
const listInventory = require('../../app/mws/fulfillmentInventory/ListInventorySupply');

router.prefix('/api/v1/inventory');
router.get('/', function (ctx, next) {
  ctx.body = 'this is a listInventory response!'
});

router.get('/listing', async (ctx, next) => {
  const sellerId = ctx.headers.sellerid;
  const mwsAuthToken = ctx.headers.mwsauthtoken;
  // const marketplaceid = ctx.query.marketplaceid;

  try {
    let json = await listInventory.listInventorySupply(sellerId, mwsAuthToken);
    ctx.response.status = 200;
    ctx.response.body = {
      data: json,
    };
  } catch (error) {
    ctx.response.status = 500;
    ctx.response.body = {
      data: error,
    };
  }
});

module.exports = router;